<?php
/**
 * 自定义函数
 */


//日期
function toDate(){
    return date('Y-m-d H:i:s');
}


//用户编号
function toUserno(){
    return date('YmdHis', time()) . rand(1000, 9999);
}


//用户token
function toToken(){
    return md5(date('YmdHis', time()) . rand(1000, 9999));
}


//自定义打印
function ddd($d1, $d2 = '', $d3 = '', $d4 = '', $d5 = ''){
    echo '<pre>';
    var_dump($d1);
    if ($d2) var_dump($d2);
    if ($d3) var_dump($d3);
    if ($d4) var_dump($d4);
    if ($d5) var_dump($d5);
    exit;
}


//今天起始
function toToday(){
    $day = date('Y-m-d', time());
    return [
        'start' => $day . ' 00:00:01',
        'end' => $day . ' 23:59:59',
    ];
}


//一周内起始
function toWeek(){
    $start = date("Y-m-d", strtotime("-6 days"));
    $end = date("Y-m-d", time());
    return [
        'start' => $start . ' 00:00:01',
        'end' => $end . ' 23:59:59',
    ];
}


//一周内起始
function toMonth(){
    return [
        'start' => date('Y-m-01 00:00:00', time()),
        'end' => date('Y-m-t 23:59:59', time()),
    ];
}


//项目名
function toItemName(){
    return 'ITEM' . time() . rand(1000, 9999);
}


//项目编号
function toItemSerial(){
    return 'XM' . time() . rand(1000, 9999);
}


//用户项目编号
function toUserItemSerial(){
    return 'UXM' . time() . rand(1000, 9999);
}


//字段名
function toFieldName(){
    return 'FD' . time() . rand(1000, 9999);
}